<?php

namespace App\Admin\Actions\Post;

use App\Imports\BannedNoticeLogImport;
use Encore\Admin\Actions\Action;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;

class ImportBannedNoticeLogPost extends Action
{
    protected $selector = '.import-banned-notice-log-post';

    public function handle(Request $request)
    {
        $file = $request->file('file');

        Excel::import(New BannedNoticeLogImport(), $file);

        return $this->response()->success('导入成功')->refresh();
    }

    public function form()
    {
        $this->file('file', '请选择文件');
    }

    public function html()
    {
        return <<<HTML
        <a class="btn btn-sm btn-default import-banned-notice-log-post">导入违规公示名单数据</a>
HTML;
    }
}
